<template :style="dataTable">
	<section>
		<!--工具条-->
		<el-col :span="24" class="toolbar" style="padding-bottom: 0px;">
			<el-form :inline="true" :model="filters">
				<el-form-item label="项目名称">
					<el-input v-model="filters.name" placeholder="输入项目名称"></el-input>
				</el-form-item>
				<el-form-item label="项目名称">
					<el-date-picker v-model="params.time" type="month" placeholder="选择时间"></el-date-picker>
				</el-form-item>
				<el-form-item>
					<el-button type="primary" @click="serBtn()">查询</el-button>
				</el-form-item>
			</el-form>
		</el-col>
		{{dataList}}
		<!--列表-->
		<!--<el-table :height=heightData   :data="dataList"  border header-align="center"  highlight-current-row v-loading="listLoading" @selection-change="selsChange" style="width: 100%;">-->
			<!--<el-table-column type="index" align="center" width="50">-->
			<!--</el-table-column>-->
			<!--<el-table-column prop="projectName" label="项目名称" align="center"  min-width="100">-->
			<!--</el-table-column>-->
		<!--</el-table>-->

		<!--工具条-->
		<el-col :span="24" class="toolbar">
			<!--<el-button type="danger" @click="batchRemove" :disabled="this.sels.length===0">批量删除</el-button>-->
			<el-pagination  @size-change="handleSizeChange" @current-change="handleCurrentChange"
							:current-page="params.page"   :page-sizes="[10, 20, 30, 40,50,200]"
							:page-size="params.pageSize"  layout="total, sizes, prev, pager, next, jumper" :total="totalRecord" style="float:right;">
			</el-pagination>
		</el-col>
	</section>
</template>

<script>
    import util from '../../common/js/util'
    import insurance from '../../api/insurance';
    import { getUserListPage, removeUser, batchRemoveUser, editUser, addUser } from '../../api/api';

    export default {
        data() {
            return {
                params: {
                    time:'2016-08',
                    page: 1,     //  当前页
                    pageSize: 10,    //  每页行数
                },
				userId:0,
                userList:[],
                totalRecord:0,  //  总记录数
                filters:{'name':''},
                dataList:[],
                total: 0,
                page: 1,
                listLoading: false,
                sels: [],//列表选中列

                heightData: document.body.clientHeight-260,
                dataTable:document.body.clientHeight-260,
            }
        },
        methods: {
            // 查询
            serBtn(){
                this.getProList();     // 调用公共列表方法
            },
            //  每页行数 选择事件
            handleSizeChange(val) {
                this.params.pageSize = val;        // 分页参数 每页行数 （赋值全局变量）
                this.getProList();  // 调用公共列表方法
            },

            // 当前页数 点击事件
            handleCurrentChange(val) {
                this.params.page  = val;    // 分页参数 当前页数 （赋值全局变量）
                this.getProList();     // 调用公共列表方法
            },
            //获取项目列表
            getProList() {
                this.listLoading = true;
                var that = this;
                var d = new Date(that.params.time);
                $.ajax(insurance.posturl+"count/time?id="+that.userId+"&year="+d.getFullYear()+"&month="+parseInt(d.getMonth()+1),{
                    headers: {'Content-Type': 'application/json;charset=UTF-8'},
                    'type': 'GET',
                     success:function (res) {
                        console.log(res);
                        res = JSON.parse(res);
                        that.totalRecord = res.count;
                        var data = [];
                        for(var i = 0; i<res.details.length; i++){
                            var d = {};
                            res.details[i].start_date = that.dateR(res.details[i].start_date);
                            res.details[i].end_date = that.dateR2(res.details[i].end_date);
                            for(var k = 0; k<that.userList.length; k++){
                                if(res.details[i].owner_id == that.userList[k].key){
                                    res.details[i].parent = that.userList[k].label;
                                    d = res.details[i];
                                }
                            }
                            data.push(d);
                        }
                        that.dataList = res.details;
                        that.listLoading = false;
                    }
                });
            },
        },
        mounted() {
            this.userId = parseInt(this.$route.query.ID);
            var t = new Date;
            this.params.time = t.getFullYear() +'-'+ parseInt(t.getMonth()+1);
            this.getProList();
        }
    }

</script>

<style scoped>

</style>